package com.itboye.allshengmedical.sci.packet.req;

import android.Manifest.permission;

import com.itboye.allshengmedical.sci.HexHelper;

public class AreaCalibrationReqPacket extends BaseReqPacket {
	public AreaCalibrationReqPacket() {
		this.setStart(new byte[] { (byte) 0x5A, (byte) 0xA5 });

		this.setLen((byte) 0x06);
		this.setContent(new byte[] { (byte) 0x0E, (byte) 0x00, (byte) 0x00,
				(byte) 0x00, (byte) 0x00, (byte) 0x00 });

		this.calCheckBit();

		this.setEnd(new byte[] { (byte) 0x3E, (byte) 0xE3 });
	}

	public void setArea01(int temp) {
		byte ctrlMod = this.getContent(1);
		this.setContent(1, (byte) (ctrlMod | 0x01));
		if (temp < 0) {
			this.setContent(2, (byte) (0x01));
			temp = -temp;
		} else {
			this.setContent(2, (byte) (0x00));
		}
		byte[] byteTemp = HexHelper.intToBytes(temp);
		this.setContent(3, byteTemp[1]);
		this.setContent(4, byteTemp[0]);
	}

	public void setArea02(int temp) {
		byte ctrlMod = this.getContent(1);
		this.setContent(1, (byte) (ctrlMod | 0x02));
		if (temp < 0) {
			temp = -temp;
			this.setContent(2, (byte) (0x01));
		} else {
			this.setContent(2, (byte) (0x00));
		}
		byte[] byteTemp = HexHelper.intToBytes(temp);
		this.setContent(3, byteTemp[1]);
		this.setContent(4, byteTemp[0]);
	}

	public void setArea03(int temp) {
		byte ctrlMod = this.getContent(1);
		this.setContent(1, (byte) (ctrlMod | 0x03));
		if (temp < 0) {
			temp = -temp;
			this.setContent(2, (byte) (0x01));
		} else {
			this.setContent(2, (byte) (0x00));
		}
		byte[] byteTemp = HexHelper.intToBytes(temp);
		this.setContent(3, byteTemp[1]);
		this.setContent(4, byteTemp[0]);
	}

	public void setArea04(int temp) {
		byte ctrlMod = this.getContent(1);
		this.setContent(1, (byte) (ctrlMod | 0x04));
		if (temp < 0) {
			temp = -temp;
			this.setContent(2, (byte) (0x01));
		} else {
			this.setContent(2, (byte) (0x00));
		}
		byte[] byteTemp = HexHelper.intToBytes(temp);
		this.setContent(3, byteTemp[1]);
		this.setContent(4, byteTemp[0]);
	}

	public void setArea05(int temp) {
		byte ctrlMod = this.getContent(1);
		this.setContent(1, (byte) (ctrlMod | 0x05));
		if (temp < 0) {
			temp = -temp;
			this.setContent(2, (byte) (0x01));
		} else {
			this.setContent(2, (byte) (0x00));
		}
		byte[] byteTemp = HexHelper.intToBytes(temp);
		this.setContent(3, byteTemp[1]);
		this.setContent(4, byteTemp[0]);
	}
}
